//
//  PaymentSuccessViewController.m
//  shanHaiHuiApp
//
//  Created by DS on 2018/3/12.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "PaymentSuccessViewController.h"
#import "GoodSuccessTableViewCell.h"
#import "CardTableViewCell.h"
#import "CardHeaderView.h"

#import "MemSelfView.h"
#import "MemDispatchView.h"
#import "StoreDispatchView.h"

#import "DispatchViewController.h"

@interface PaymentSuccessViewController ()<UITableViewDelegate,UITableViewDataSource>

Strong UITableView * tableView;

Strong UIView * headerView;

//footView
Strong UIView * footView;
Strong UILabel * cardLabel;
Strong UILabel * moneyLabel;
Strong UIView * lineView1;

//会员卡支付
Strong UIImageView * cardImageView;
Strong UILabel * cardNameLabel;
Strong UILabel * cardMoneyLabel;
Strong UIView * cardLineView;
//支付后余额
Strong UIImageView * restantImageView;
Strong UILabel * restantNameLabel;
Strong UILabel * restantMoneyLabel;
Strong UIView * restantLineView;
//现金支付
Strong UIImageView * cashImageView;
Strong UILabel * cashNameLabel;
Strong UILabel * cashMoneyLabel;
Strong UIView * cashLineView;
//找零
Strong UIImageView * changeImageView;
Strong UILabel * changeNameLabel;
Strong UILabel * changeMoneyLabel;
Strong UIView * changeLineView;
//卡号
Strong UIImageView * numberImageView;
Strong UILabel * numberNameLabel;
Strong UILabel * numberMoneyLabel;
Strong UIView * numberLineView;
//手机号
Strong UIImageView * phoneImageView;
Strong UILabel * phoneNameLabel;
Strong UILabel * phoneMoneyLabel;
Strong UIView * phoneLineView;
//姓名
Strong UIImageView * nameImageView;
Strong UILabel * nameNameLabel;
Strong UILabel * nameMoneyLabel;
Strong UIView * nameLineView;

Strong UILabel * storeLabel;

//底部视图
Strong UILabel * bottomLabel;

//会员自提头部视图

Strong MemSelfView * memSelfView;
Strong MemDispatchView * memDispatchView;
Strong StoreDispatchView * storeDispatchView;
Strong  StoreDispatchView * storeSelfView;


//商品批号比较
Strong NSString * strGood;
Strong NSString * strSpph;

//订单时间
Strong NSString * fDatetime;
Strong NSString * disttime;


@end

//网络
@implementation PaymentSuccessViewController (NetWorking)
//成功接口
- (void)comPeleteData{
    [self showprogressHUD];
    NSDictionary *parameters = @{
                                 @"orderNo":self.orderNo,
                                 };
    [[AFAppDotNetAPIClient sharedClient] POST:@"morderDistFinish.do" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [self hiddenProgressHUD];
        if ([responseObject[@"code"] intValue] == 0) {
            DispatchViewController * vc = [[DispatchViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
            
        }else{
            ShowMessage(responseObject[@"msg"]);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self hiddenProgressHUD];
        [self showError:error];
    }];
}
@end


@implementation PaymentSuccessViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self NavColor];
}

// 导航颜色
- (void)NavColor{
    
    UINavigationBar * bar = self.navigationController.navigationBar;
    UIImage *bgImage = [UIImage imageWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64) WihtColor:getColor(navColor) alphe:1.0];
    [bar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    
    
    [bar setShadowImage:[UIImage imageWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0.1) WihtColor:[UIColor blackColor] alphe:1.0]];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.bottomLabel];
    self.title = @"支付成功";
//    if (self.orderDicSuccess[@"fDatetime"] == nil) {
//        return;
//    }else{
//        NSDictionary * dic = self.orderDicSuccess[@"fDatetime"];
//        self.fDatetime = [NSString stringWithFormat:@"%@-%@-%@ %@:%@", [dic objectForKey:@"year"],[dic objectForKey:@"month"],[dic objectForKey:@"day"],[dic objectForKey:@"hours"],[dic objectForKey:@"minutes"]];
//    }
    
//    if (self.orderDicSuccess[@"disttime"] == nil) {
//        return;
//    }else{
//        NSDictionary * dic = self.orderDicSuccess[@"disttime"];
//        self.disttime = [NSString stringWithFormat:@"%@-%@-%@ %@:%@", [dic objectForKey:@"year"],[dic objectForKey:@"month"],[dic objectForKey:@"day"],[dic objectForKey:@"hours"],[dic objectForKey:@"minutes"]];
//    }
}

//完成点击
- (void)tapClick:(UIGestureRecognizer *)sender{
    
   [self comPeleteData];
    DispatchViewController * vc = [[DispatchViewController alloc] init];
    vc.title = [UserModel sharedInstanced].userID;
    [self.navigationController pushViewController:vc animated:YES];

}

//去掉小数点后面的0
-(NSString*)removeFloatAllZero:(NSString*)string
{
    NSString * testNumber = string;
    NSString * outNumber = [NSString stringWithFormat:@"%@",@(testNumber.floatValue)];
    return outNumber;
}

#pragma init --

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - height64 - UNIT_HEIGHT(49)) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.sectionFooterHeight = .01;
        _tableView.sectionHeaderHeight = .01;
        _tableView.tableFooterView = self.footView;
        _tableView.tableHeaderView = self.headerView;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.showsHorizontalScrollIndicator = NO;
        _tableView.bounces = NO;
    }
    return _tableView;
}

- (UIView *)headerView{
    
    ws(self)
    
    if(!_headerView){
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(300))];
        _headerView.backgroundColor = getColor(whiteColor);
  
        if ([self.dispatchType isEqualToString:@"会员自提"]) {
            
            if (!_memSelfView) {
                _memSelfView = [[MemSelfView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(44))];
            }
            [_headerView addSubview:self.memSelfView];
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(44));
        }else if ([self.dispatchType isEqualToString:@"会员配送"]){
            if (!_memDispatchView) {
                _memDispatchView = [[MemDispatchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(260))];
            }
            
            _memDispatchView.personLabel.text = [NSString stringWithFormat:@"收货人:%@",[UserModel sharedInstanced].personTestStr];
            _memDispatchView.phoneLabel.text = [UserModel sharedInstanced].contactTestStr;
            _memDispatchView.adressLabel.text = [UserModel sharedInstanced].adressTestStr;
            _memDispatchView.remarkLabel.text = [NSString stringWithFormat:@"配送备注:%@",[UserModel sharedInstanced].memDisTestStr];
            ws( _memDispatchView)
            _memDispatchView.getCongfigClick = ^{
                //弹出是否确认配送
                UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"是否确认配送"
                                                                               message:nil
                                                                        preferredStyle:UIAlertControllerStyleAlert];
                
                UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault
                handler:^(UIAlertAction * action) {
                //确认配送显示配送人和配送时间
                   weak_memDispatchView.configBtn.hidden = YES;
                   weak_memDispatchView.configLabel.hidden = NO;
                    NSString * str = weakself.orderDicSuccess[@"distuserid"];
                    weak_memDispatchView.configLabel.text = [NSString stringWithFormat:@"配送人员:%@",str];
                   weak_memDispatchView.timeLabel.hidden = NO;
                    
                    weak_memDispatchView.timeLabel.text = [NSString stringWithFormat:@"配送时间:%@",weakself.disttime];
                                                }];
                UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault
                    handler:^(UIAlertAction * action) {
                                                                         
                                                }];
                
                [alert addAction:defaultAction];
                [alert addAction:cancelAction];
                [weakself presentViewController:alert animated:YES completion:nil];
              
            };
            [_headerView addSubview:self.memDispatchView];
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, UNIT_WIDTH(260));
            
        }else if ([self.dispatchType isEqualToString:@"门店配送"]){
            
            if (!_storeDispatchView) {
                _storeDispatchView = [[StoreDispatchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(220))];
                _storeDispatchView.storeLabel.text = [NSString stringWithFormat:@"配送门店:%@",[UserModel sharedInstanced].fMemo1];
                _storeDispatchView.remarkLabel.text = [NSString stringWithFormat:@"配送备注:%@",[UserModel sharedInstanced].shopTestStr];
                _storeDispatchView.dispatchNameLabel.text = [NSString stringWithFormat:@"配送人员:%@",self.orderDicSuccess[@"distuserid"]];
                _storeDispatchView.timeLabel.text = [NSString stringWithFormat:@"配送时间:%@",self.disttime];
            }
            [_headerView addSubview:self.storeDispatchView];
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, UNIT_WIDTH(220));
            
        }else if ([self.dispatchType isEqualToString:@"门店自提"]){
            if (!_storeSelfView) {
                _storeSelfView = [[StoreDispatchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(220))];
            }
            
            _storeSelfView.storeLabel.text = [NSString stringWithFormat:@"配送门店:%@",[UserModel sharedInstanced].fMemo1];
            _storeSelfView.remarkLabel.text = [NSString stringWithFormat:@"配送备注:%@",[UserModel sharedInstanced].storeTestStr];
            _storeDispatchView.dispatchNameLabel.text = [NSString stringWithFormat:@"配送人员:%@",self.orderDicSuccess[@"distuserid"]];
            _storeDispatchView.timeLabel.text = [NSString stringWithFormat:@"配送时间:%@",self.disttime];
            
            [_headerView addSubview:self.storeSelfView];
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, UNIT_WIDTH(220));
            
        }
    }
    return _headerView;
}
- (UIView *)footView{
    if (!_footView) {
        _footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH, UNIT_HEIGHT(450))];
        _footView.backgroundColor = [UIColor whiteColor];
        
        _cardLabel = [[UILabel alloc] init];
        //_cardLabel.text = @"单号: 012180000535";
        _cardLabel.text = [NSString stringWithFormat:@"单号:%@",self.orderNo];
        _cardLabel.font = DEF_FontSize_11;
        _cardLabel.textColor = getColor(@"323232");
        
        _moneyLabel = [[UILabel alloc] init];
        //_moneyLabel.text = @"总计 : 200元";
        _moneyLabel.text = [NSString stringWithFormat:@"总计:￥%@",self.orderDicSuccess[@"orderXsje"]];
        _moneyLabel.textColor = getColor(@"EC4350");
        _moneyLabel.font = DEF_FontSize_14;
        
        _lineView1 = [[UIView alloc] init];
        _lineView1.backgroundColor = getColor(@"F0F0F0");
        
        //会员卡支付
        _cardImageView = [UIImageView new];
        _cardImageView.image = [UIImage imageNamed:@"huiyuanka"];
        _cardImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _cardNameLabel = [[UILabel alloc] init];
        _cardNameLabel.font = DEF_FontSize_14;
        _cardNameLabel.textColor = getColor(@"666666");
        _cardNameLabel.text = @"会员卡支付";
        
        _cardMoneyLabel = [[UILabel alloc] init];
        _cardMoneyLabel.textColor = getColor(@"323232");
        _cardMoneyLabel.font = DEF_FontSize_14;
        //_cardMoneyLabel.text = @"100.00元";
        _cardMoneyLabel.text = [NSString stringWithFormat:@"￥%@",self.memCardSuccess];
        
        _cardLineView = [[UIView alloc] init];
        _cardLineView.backgroundColor = getColor(dividerColor);
        
        //支付后余额
        _restantImageView = [UIImageView new];
        _restantImageView.image = [UIImage imageNamed:@"yue"];
        _restantImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _restantNameLabel = [[UILabel alloc] init];
        _restantNameLabel.font = DEF_FontSize_14;
        _restantNameLabel.textColor = getColor(@"666666");
        _restantNameLabel.text = @"支付后余额";
        
        _restantMoneyLabel = [[UILabel alloc] init];
        _restantMoneyLabel.textColor = getColor(@"323232");
        _restantMoneyLabel.font = DEF_FontSize_14;
        
        float remainMoney = ([self.orderDicSuccess[@"fCardMoney"] floatValue] - [self.orderDicSuccess[@"orderXsje"] floatValue]) ;
         if (remainMoney > 0) {
             NSString * str = [NSString stringWithFormat:@"%f",remainMoney];
             
            NSString * str2 = [self removeFloatAllZero:str];
             
             _restantMoneyLabel.text = [NSString stringWithFormat:@"￥%@",str2];
         }else{
             _restantMoneyLabel.text = [NSString stringWithFormat:@"￥%@",@"0"];
         }
       
        
        _restantLineView = [[UIView alloc] init];
        _restantLineView.backgroundColor = getColor(dividerColor);
        
        //现金支付
        _cashImageView = [UIImageView new];
        _cashImageView.image = [UIImage imageNamed:@"xianjin"];
        _cashImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _cashNameLabel = [[UILabel alloc] init];
        _cashNameLabel.font = DEF_FontSize_14;
        _cashNameLabel.textColor = getColor(@"666666");
        _cashNameLabel.text = @"现金支付";
        
        _cashMoneyLabel = [[UILabel alloc] init];
        _cashMoneyLabel.textColor = getColor(@"323232");
        _cashMoneyLabel.font = DEF_FontSize_14;
        //_cashMoneyLabel.text = @"100.00元";
        _cashMoneyLabel.text = [NSString stringWithFormat:@"￥%@",self.cashPaySuccess];
        
        _cashLineView = [[UIView alloc] init];
        _cashLineView.backgroundColor = getColor(dividerColor);
        
        //找零
        _changeImageView = [UIImageView new];
        _changeImageView.image = [UIImage imageNamed:@"zhaoling"];
        _changeImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _changeNameLabel = [[UILabel alloc] init];
        _changeNameLabel.font = DEF_FontSize_14;
        _changeNameLabel.textColor = getColor(@"666666");
        _changeNameLabel.text = @"找零";
        
        _changeMoneyLabel = [[UILabel alloc] init];
        _changeMoneyLabel.textColor = getColor(@"323232");
        _changeMoneyLabel.font = DEF_FontSize_14;
        //_changeMoneyLabel.text = @"100.00元";
        _changeMoneyLabel.text = [NSString stringWithFormat:@"￥%@",self.changeMoneySuccess];
        
        _changeLineView = [[UIView alloc] init];
        _changeLineView.backgroundColor = getColor(@"F0F0F0");
        
        //卡号
        _numberImageView = [UIImageView new];
        _numberImageView.image = [UIImage imageNamed:@"huiyuanka拷贝"];
        _numberImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _numberNameLabel = [[UILabel alloc] init];
        _numberNameLabel.font = DEF_FontSize_14;
        _numberNameLabel.textColor = getColor(@"666666");
        //_numberNameLabel.text = @"卡号123456";
        _numberNameLabel.text = [NSString stringWithFormat:@"卡号%@",self.orderDicSuccess[@"fCardno"]];
        
        _numberMoneyLabel = [[UILabel alloc] init];
        _numberMoneyLabel.textColor = getColor(@"323232");
        _numberMoneyLabel.font = DEF_FontSize_14;
        //_numberMoneyLabel.text = @"尼古拉斯";
        _numberMoneyLabel.text = self.orderDicSuccess[@"fName"];
        
        _numberLineView = [[UIView alloc] init];
        _numberLineView.backgroundColor = getColor(dividerColor);
        
        //手机号
        _phoneImageView = [UIImageView new];
        _phoneImageView.image = [UIImage imageNamed:@"shouji"];
        _phoneImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _phoneNameLabel = [[UILabel alloc] init];
        _phoneNameLabel.font = DEF_FontSize_14;
        _phoneNameLabel.textColor = getColor(@"666666");
        _phoneNameLabel.text = @"手机号";
        
        _phoneMoneyLabel = [[UILabel alloc] init];
        _phoneMoneyLabel.textColor = getColor(@"323232");
        _phoneMoneyLabel.font = DEF_FontSize_14;
        //_phoneMoneyLabel.text = @"11111111111";
        _phoneMoneyLabel.text = self.orderDicSuccess[@"fMobiletel"];
        
        _phoneLineView = [[UIView alloc] init];
        _phoneLineView.backgroundColor = getColor(@"F0F0F0");
        
        //名字
        _nameImageView = [UIImageView new];
        _nameImageView.image = [UIImage imageNamed:@"zhaoling"];
        _nameImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        _nameNameLabel = [[UILabel alloc] init];
        _nameNameLabel.font = DEF_FontSize_14;
        _nameNameLabel.textColor = getColor(@"666666");
        //_nameNameLabel.text = @"王晓明";
        _nameNameLabel.text = [UserModel sharedInstanced].userID;
        
        //时间
        _nameMoneyLabel = [[UILabel alloc] init];
        _nameMoneyLabel.textColor = getColor(@"323232");
        _nameMoneyLabel.font = DEF_FontSize_14;
        _nameMoneyLabel.text = self.fDatetime;

        
        
        _nameLineView = [[UIView alloc] init];
        _nameLineView.backgroundColor = getColor(@"F0F0F0");
        
        _storeLabel = [[UILabel alloc] init];
       // _storeLabel.text = @"山海慧哈尔滨路点";
        _storeLabel.textColor = getColor(@"323232");
        _storeLabel.font = DEF_FontSize_14;
        _storeLabel.text = [UserModel sharedInstanced].fMemo;
        
   
        [_footView sd_addSubviews:@[self.cardLabel,self.moneyLabel,self.lineView1,self.cardImageView,self.cardNameLabel,self.cardMoneyLabel,self.cardLineView,self.restantImageView,self.restantNameLabel,self.restantMoneyLabel,self.restantLineView,self.cashImageView,self.cashNameLabel,self.cashMoneyLabel,self.cashLineView,self.changeImageView,self.changeNameLabel,self.changeMoneyLabel,self.changeLineView,self.numberImageView,self.numberNameLabel,self.numberMoneyLabel,self.numberLineView,self.phoneImageView,self.phoneNameLabel,self.phoneMoneyLabel,self.phoneLineView,self.nameImageView,self.nameNameLabel,self.nameMoneyLabel,self.nameLineView,self.storeLabel]];
        [self layOutFrame];
    }
    return _footView;
}

- (void)layOutFrame{
    ws(self)
    [self.cardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(15));
        make.top.mas_equalTo(UNIT_HEIGHT(18));
        make.height.mas_equalTo(UNIT_WIDTH(30));
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.top.mas_equalTo(UNIT_HEIGHT(18));
        make.height.mas_equalTo(UNIT_WIDTH(30));
    }];
    
    [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.moneyLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(5);
    }];
    
    //会员卡支付
    
    [self.cardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.lineView1.mas_bottom).offset(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(16));
        make.height.mas_equalTo(UNIT_HEIGHT(17));
        make.width.mas_equalTo(UNIT_WIDTH(21));
    }];
    
    [self.cardNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.cardImageView.mas_right).offset(UNIT_WIDTH(15));
        make.centerY.mas_equalTo(weakself.cardImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.cardMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.centerY.mas_equalTo(weakself.cardImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.cardLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.cardImageView.mas_bottom).offset(UNIT_HEIGHT(10));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
    
    //支付后余额
    [self.restantImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.cardLineView.mas_bottom).offset(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(16));
        make.height.mas_equalTo(UNIT_HEIGHT(17));
        make.width.mas_equalTo(UNIT_WIDTH(21));
    }];
    
    [self.restantNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.restantImageView.mas_right).offset(UNIT_WIDTH(15));
        make.centerY.mas_equalTo(weakself.restantImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.restantMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.centerY.mas_equalTo(weakself.restantImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.restantLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.restantImageView.mas_bottom).offset(UNIT_HEIGHT(10));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
  
    //现金支付
    [self.cashImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.restantLineView.mas_bottom).offset(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(16));
        make.height.mas_equalTo(UNIT_HEIGHT(17));
        make.width.mas_equalTo(UNIT_WIDTH(21));
    }];
    
    [self.cashNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.cashImageView.mas_right).offset(UNIT_WIDTH(15));
        make.centerY.mas_equalTo(weakself.cashImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.cashMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.centerY.mas_equalTo(weakself.cashImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.cashLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.cashImageView.mas_bottom).offset(UNIT_HEIGHT(10));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
    
    //找零
    [self.changeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.cashLineView.mas_bottom).offset(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(16));
        make.height.mas_equalTo(UNIT_HEIGHT(17));
        make.width.mas_equalTo(UNIT_WIDTH(21));
    }];
    
    [self.changeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.changeImageView.mas_right).offset(UNIT_WIDTH(15));
        make.centerY.mas_equalTo(weakself.changeImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.changeMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.centerY.mas_equalTo(weakself.changeImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.changeLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.changeImageView.mas_bottom).offset(UNIT_HEIGHT(10));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(5);
    }];
    
    //卡号
    [self.numberImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.changeLineView.mas_bottom).offset(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(16));
        make.height.mas_equalTo(UNIT_HEIGHT(17));
        make.width.mas_equalTo(UNIT_WIDTH(21));
    }];
    
    [self.numberNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.numberImageView.mas_right).offset(UNIT_WIDTH(15));
        make.centerY.mas_equalTo(weakself.numberImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.numberMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.centerY.mas_equalTo(weakself.numberImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.numberLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.numberImageView.mas_bottom).offset(UNIT_HEIGHT(10));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
    
    //手机号
    [self.phoneImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.numberLineView.mas_bottom).offset(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(16));
        make.height.mas_equalTo(UNIT_HEIGHT(17));
        make.width.mas_equalTo(UNIT_WIDTH(21));
    }];
    
    [self.phoneNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.phoneImageView.mas_right).offset(UNIT_WIDTH(15));
        make.centerY.mas_equalTo(weakself.phoneImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.phoneMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.centerY.mas_equalTo(weakself.phoneImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.phoneLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.phoneImageView.mas_bottom).offset(UNIT_HEIGHT(10));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(5);
    }];
    
    //姓名
    [self.nameImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.phoneLineView.mas_bottom).offset(UNIT_HEIGHT(15));
        make.left.mas_equalTo(UNIT_WIDTH(16));
        make.height.mas_equalTo(UNIT_HEIGHT(17));
        make.width.mas_equalTo(UNIT_WIDTH(21));
    }];
    
    [self.nameNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.nameImageView.mas_right).offset(UNIT_WIDTH(15));
        make.centerY.mas_equalTo(weakself.nameImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.nameMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.centerY.mas_equalTo(weakself.nameImageView.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.nameLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.nameImageView.mas_bottom).offset(UNIT_HEIGHT(10));
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(5);
    }];
    
    [self.storeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-15));
        make.height.mas_equalTo(UNIT_HEIGHT(30));
        make.top.mas_equalTo(weakself.nameLineView.mas_bottom).offset(UNIT_HEIGHT(15));
    }];
 
}


- (UILabel *)bottomLabel{
    
    if (!_bottomLabel) {
        _bottomLabel = [[UILabel alloc] init];
        _bottomLabel.frame = CGRectMake(0,CGRectGetMaxY(self.tableView.frame), SCREEN_WIDTH, UNIT_HEIGHT(49));
        _bottomLabel.text = @"完成";
        _bottomLabel.font = DEF_FontSize_14;
        _bottomLabel.textColor = getColor(whiteColor);
        _bottomLabel.textAlignment = NSTextAlignmentCenter;
        _bottomLabel.backgroundColor = getColor(@"CCCCCC");
        _bottomLabel.userInteractionEnabled = YES;
        UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        [_bottomLabel addGestureRecognizer:tap];
       
    }
    return _bottomLabel;
}

#pragma mark - <UITableViewDelegate , UITableViewDataSource>

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    

    //取出商品里的商品编号
    for (PayMentGoodModel *model in self.orderArrSuccess) {
        self.strGood = model.spbh;
    }
    
    //取出商品编号里的商品编号
    for (PayMentSpphModel *model in self.orderSpphArrSuccess) {
        self.strSpph = model.fSpbh;
    }
    
    //如果商品里的商品编号和商品编号里的商品编号的编号一致,就显示对应的数据
    if ([self.strGood isEqualToString:self.strSpph]) {
        
        return self.orderSpphArrSuccess.count;
        
    }
        
    return 0;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.orderArrSuccess.count;
}




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    CardTableViewCell * cell = [CardTableViewCell cellForTableView:tableView];
    
    //取出商品里的商品编号
    for (PayMentGoodModel *model in self.orderArrSuccess) {
        self.strGood = model.spbh;
    }
    
    //取出商品编号里的商品编号
    for (PayMentSpphModel *model in self.orderSpphArrSuccess) {
        self.strSpph = model.fSpbh;
    }
    
    //如果商品里的商品编号和商品编号里的商品编号的编号一致,就显示对应的数据
    if ([self.strGood isEqualToString:self.strSpph]) {
        
        cell.model = self.orderSpphArrSuccess[indexPath.row];
    }

    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return UNIT_HEIGHT(130);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    CardHeaderView * cardView = [[CardHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, UNIT_HEIGHT(100))];
    
    
    cardView.backgroundColor = getColor(whiteColor);
    
    cardView.model = self.orderArrSuccess[section];
    
    return cardView;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return UNIT_HEIGHT(100);
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}





@end
